package cn.iocoder.yudao.module.scrm.controller.admin.customer.vo;

import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.scrm.annotations.FieldRepeatValidator;
import cn.iocoder.yudao.module.scrm.annotations.FieldRepeatValidators;
import cn.iocoder.yudao.module.scrm.controller.admin.commom.vo.FileInfoVO;
import cn.iocoder.yudao.module.scrm.framework.operatelog.core.*;
import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
import static cn.iocoder.yudao.module.scrm.enums.DictTypeConstants.*;

@Schema(description = "管理后台 - SCRM客户新增/修改 Request VO")
@Data
@FieldRepeatValidators(tableName = "scrm_customer",idField = "id",fieldRepeatValidators = {
        //@FieldRepeatValidator(field = "name", property = "name",message = "姓名已经存在！"),
        @FieldRepeatValidator(field = "phone", property = "phone",message = "手机号码已经存在！")
})
public class CustomerSaveReqVO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "8519")
    private Long id;

    @Schema(description = "姓名", example = "李四")
    @DiffLogField(name = "客户名称")
    @NotNull(message = "姓名不能为空")
    private String name;

    @Schema(description = "企业")
    @DiffLogField(name = "企业")
    private String enterprise;

    @Schema(description = "手机号码")
    @DiffLogField(name = "电话")
    @NotNull(message = "手机号码不能为空")
    private String phone;

    @Schema(description = "线索来源")
    @DiffLogField(name = "线索来源")
    private String clueSource;

    @Schema(description = "获客时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
    @DiffLogField(name = "获客时间")
    private LocalDateTime customerSourceTime;

    @Schema(description = "客户来源")
    @DiffLogField(name = "客户来源", function = ScrmClueClientFunction.NAME)
    @DictFormat(SCRM_CLUE_CLIENT)
    private String customerSource;

    @Schema(description = "素材来源")
    @DiffLogField(name = "素材来源")
    private String materialSource;

    @Schema(description = "信息来源")
    @DiffLogField(name = "信息来源", function = ScrmClueInfoFunction.NAME)
    @DictFormat(SCRM_CLUE_INFO)
    private String infoSource;

    @Schema(description = "客户质量->客户意向  scrm_clue_idea")
    @DiffLogField(name = "客户意向", function = ScrmClueIdeaFunction.NAME)
    @DictFormat(SCRM_CLUE_IDEA)
    private String clientQuality;

    @Schema(description = "备注", example = "随便")
    @DiffLogField(name = "备注")
    private String remark;

    @Schema(description = "扩展")
//    @DiffLogField(name = "扩展")
    private JSONArray extend;

    @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @DiffLogField(name = "跟进状态")
//    @NotNull(message = "跟进状态不能为空")
    private Boolean followUpStatus;

    @Schema(description = "最后跟进时间")
    @DiffLogField(name = "最后跟进时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime contactLastTime;

    @Schema(description = "最后跟进内容")
    @DiffLogField(name = "最后跟进内容")
    private String contactLastContent;

    @Schema(description = "下次联系时间")
    @DiffLogField(name = "下次联系时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime contactNextTime;

    @Schema(description = "负责人的用户编号", example = "15447")
    @DiffLogField(name = "负责人的用户编号")
    private Long ownerUserId;

    @Schema(description = "成为负责人的时间")
    @DiffLogField(name = "成为负责人的时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime ownerTime;

    @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @DiffLogField(name = "成交状态")
//    @NotNull(message = "成交状态不能为空")
    private Boolean dealStatus;

    @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @DiffLogField(name = "锁定状态")
//    @NotNull(message = "锁定状态不能为空")
    private Boolean lockStatus;

    @Schema(description = "客户等级，对应字典 SCRM_CUSTOMER_LEVEL")
    @DiffLogField(name = "客户等级")
    private Integer level;

    @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
    @DiffLogField(name = "状态")
//    @NotNull(message = "状态不能为空")
    private Integer status;







    @Schema(description = "客户阶段", example = "新客户 1")
    @DiffLogField(name = "客户阶段", function = ScrmCustomerStageFunction.NAME)
    @DictFormat(SCRM_CUSTOMER_STAGE)
    private String customerStage;

    @Schema(description = "年营业额", example = "A(1000亿以上) 1")
    @DiffLogField(name = "年营业额", function = ScrmYearTurnoverFunction.NAME)
    @DictFormat(SCRM_YEAR_TURNOVER)
    private String yearTurnover;

    @Schema(description = "分公司", example = "分公司 中创")
    @DiffLogField(name = "分公司", function = ScrmSonCompanyFunction.NAME)
    @DictFormat(SCRM_SON_COMPANY)
    private String sonCompany;

    @Schema(description = "回款方式,关联枚举CrmReceivableReturnTypeEnum", example = "1")
    @DiffLogField(name = "回款方式", function = ScrmReceivableMethodFunction.NAME)
    @DictFormat(SCRM_PAYMENT_METHOD)
    private String receivableMethod;

    @Schema(description = "峰会是否签到-状态值-显示加上Name", example = "1")
    @DiffLogField(name = "分公司", function = ScrmSummitStatusFunction.NAME)
    @DictFormat(SCRM_SUMMIT_STATUS)
    private String summitStatus;

    @Schema(description = "职位", example = "职位")
    @DiffLogField(name = "职位")
    private String position;

    @Schema(description = "身份证号", example = "身份证号")
    @DiffLogField(name = "身份证号")
    private String idCard;

    @Schema(description = "邀约人", example = "邀约人")
    @DiffLogField(name = "邀约人")
    private String inviter;

    @Schema(description = "回款金额", example = "6.66")
    @DiffLogField(name = "回款金额")
    @DecimalMin(value = "0.00", message = "金额必须为大于或者等于0.00")
    @Digits(integer = 11, fraction = 2, message = "金额只能有11个整数和两位小数")
    private BigDecimal receivablePrice;

    @Schema(description = "回款时间", example = "2020-02-02 02:02:02")
    @DiffLogField(name = "回款时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime receivableTime;



    @Schema(description = "峰会组别", example = "峰会组别")
    @DiffLogField(name = "峰会组别")
    private String summitGroup;

    @Schema(description = "员工人数", example = "员工人数")
    @DiffLogField(name = "员工人数")
    private String numberPeople;

    @Schema(description = "需求及痛点", example = "需求及痛点")
    @DiffLogField(name = "需求及痛点 ")
    private String quantityPain;

    @Schema(description = "图片-附件信息", example = "https://www.iocoder.cn")
    private List<FileInfoVO> pictureAttachment;

    @Schema(description = "附件信息", example = "https://www.iocoder.cn")
    private List<FileInfoVO> attachment;


}